import { Component, OnInit, ViewChild, ɵConsole, TemplateRef } from '@angular/core';
import { _HttpClient, ModalHelper } from '@delon/theme';
import { STColumn, STComponent, STColumnButton, STPage, STChange, STReq } from '@delon/abc';
import { SFSchema, SFComponent, SFRadioWidgetSchema } from '@delon/form';
import { GridComponent, PopdetailComponent, HttpService, SupDic } from 'lbf';
import { NzMessageService,NzModalService} from 'ng-zorro-antd';
import { delay } from 'rxjs/operators';
import { of } from 'rxjs';

@Component({
  selector: 'app-xtgn-jzmxdb',
  templateUrl: './jzmxdb.component.html',
  styleUrls: ['./jzmxdb.component.less'],
})
export class XtgnJzmxdbComponent implements OnInit {
  
  params = {sname: 'xtgn_mxdbcx',form:{MONTH: '01'}}
  xzlb: string ;
  ljbz: string;
  searchSchema: SFSchema = {
    properties: {
      AAE140: {
        type: 'string',
        title: '险种类型',
        ui: {
          widget: 'radio',
          width: 200,
          asyncData: () => of([{ label: '职工', value: '20' }, { label: '城乡', value: '25' }]).pipe(delay(100)),
        } as SFRadioWidgetSchema,
      },
      LJFLAG: {
        type: 'string',
        title: '累计标志',
        ui: {
          widget: 'radio',
          width: 200,
          asyncData: () => of([{ label: '是', value: '1' }, { label: '否', value: '0' }]).pipe(delay(100)), 
        } as SFRadioWidgetSchema,
      },  
      MONTH: {
        type: 'string',
        title: '月数',
        ui: {
          widget: 'select',
          width: 150
        },
        enum:
        [
          { label: '1月', value: '01' },
          { label: '2月', value: '02' },
          { label: '3月', value: '03' },
          { label: '4月', value: '04' },
          { label: '5月', value: '05' },
          { label: '6月', value: '06' },
          { label: '7月', value: '07' },
          { label: '8月', value: '08' },
          { label: '9月', value: '09' },
          { label: '10月', value: '10' },
          { label: '11月', value: '11' },
          { label: '12月', value: '12' },
        ],
        default: '1月'
      },
      AKE156: {
        type: 'string',
        title: '结算范围',
        enum: this.supdic.getSFDic('AKE156'),
        ui: {
          widget: 'select',
          allowClear: true,
          width: 200
        },
      },
      AKC001 : {
        type: 'string',
        title: '就诊类型',
        enum: this.supdic.getSFDic('AKC001'),
        ui: {
          widget: 'select',
          allowClear: true,
          width: 200
        }
      }
    }
  };
  @ViewChild('st', { static: false }) st: GridComponent;
  @ViewChild('sf', { static: false }) sf: SFComponent ;
  columns: STColumn[] = [
    {title: "(按报销金额)",index: "AKB002"},
    {title: "人头",index: "RT2020",format:(item) => this.rtfz2020(item)},
    {title: "人次",index: "RC2020",format:(item) => this.rcfz2020(item)},
    {title: "总金额",index: "AKC0462020",type: 'number',format:(item) => this.zjefz2020(item)},
    {title: "报销金额",index: "AKC3702020",type: 'number',format:(item) => this.bxjefz2020(item)},
    {title: "次均费用",index: "CJFY2020",type: "number"},
    {title: "人头",index: "RT2019",format:(item) => this.rtfz2019(item) },
    {title: "人次",index: "RC2019",format:(item) => this.rcfz2019(item)},
    {title: "总金额",index: "AKC0462019",type: 'number',format:(item) => this.zjefz2019(item)},
    {title: "报销金额",index: "AKC3702019",type: 'number',format:(item) => this.bxjefz2019(item)},
    {title: "次均费用",index: "CJFY2019",type: "number"}
  ];

  constructor(
    private modal: ModalHelper,
    public msgSrv: NzMessageService,
    private lbservice: HttpService,
    private supdic: SupDic,
    private modalService: NzModalService
  ) { }

  ngOnInit(
  ) {}

  rtfz2020(item){
    return item.RT2020+'万';
  }

  rtfz2019(item){
    return item.RT2019+'万';
  }

  rcfz2020(item){
    return item.RC2020+'万';
  }
  zjefz2020(item){
    return item.AKC0462020+'万';
  }
  bxjefz2020(item){
    return item.AKC3702020+'万';
  }
  rcfz2019(item){
    return item.RC2019+'万';
  }
  zjefz2019(item){
    return item.AKC0462019+'万';
  }
  bxjefz2019(item){
    return item.AKC3702019+'万';
  }

  query(){
    console.log(this.sf.value);
    this.st.reload(this.sf.value);
  }

  reset(){
    this.sf.reset();
    this.st.reload({MONTH: '01'});
  }
}
